﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Phoenix.AppCode.Entities;
using Phoenix.AppCode.Data;
using System.Data;

namespace Phoenix.AppCode.Bussiness
{
    public class UsersService
    {
        #region Backend Method
        /// <summary>
        /// Create 
        /// </summary>
        /// <param name="users"></param>
        public static void Create(Users users)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.Create(users);
        }

        /// <summary>
        /// Edit
        /// </summary>
        /// <param name="users"></param>
        public static void Edit(Users users)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.Edit(users);
        }

        /// <summary>
        /// Change Profile user
        /// </summary>
        /// <param name="users"></param>
        public static void EditProfile(Users users)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.Edit(users);
        }

        /// <summary>
        /// Change password
        /// </summary>
        /// <param name="users"></param>
        public static void ChangePassword(Users users)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.UsersChangePassword(users);
        }

        /// <summary>
        /// Update datetime lastlogin
        /// </summary>
        /// <param name="idusers"></param>
        public static void UsersLastLogin(String idusers)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.UsersLastLogin(idusers);
        }

        /// <summary>
        /// Update datetime lastlogout
        /// </summary>
        /// <param name="idusers"></param>
        public static void UsersLastLogout(String idusers)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.UsersLastLogout(idusers);
        }

        /// <summary>
        /// Add permission
        /// </summary>
        /// <param name="idusers"></param>
        /// <param name="idmenulist"></param>
        public static void AddPermisson(String idusers, int idmenulist)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.UsersMenuListAddPermission(idusers,idmenulist);
        }

        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="users"></param>
        public static void Delete(Users users)
        {
            UsersDAO usersDAO = new UsersDAO();
            usersDAO.Delete(users);
        }

        public static DataTable UsersLogin(string usersname, string pass)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UsersLogin(usersname, pass);
        }

        /// <summary>
        /// Show all users
        /// </summary>
        /// <param name="language"></param>
        /// <returns></returns>
        public static DataTable UsersList(string idusers)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UsersList(idusers);
        }

        /// <summary>
        /// Show all menu control of user
        /// </summary>
        /// <param name="idusers"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public static DataTable UserMenuListControl(String idusers, String language)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UserMenuListControl(idusers, language);
        }

        /// <summary>
        /// Show all menulist permission backend
        /// </summary>
        /// <returns></returns>
        public static DataTable UsersMenuListPermission(String idusers, String language)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UsersMenuListPermission(idusers, language);
        }

        /// <summary>
        /// Show data by ID
        /// </summary>
        /// <param name="idusers"></param>
        /// <returns></returns>
        public static DataTable UsersList_GetByID(int idusers)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UsersList_GetByID(idusers);
        }

        /// <summary>
        /// Get ID to edit or delete 
        /// </summary>
        /// <param name="idusers"></param>
        /// <returns></returns>
        public static Users GetUsersByID(int idusers)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.GetUsersByID(idusers);
        }

        public static DataTable UsersMenuListCheck(String idusers, String url)
        {
            UsersDAO usersDAO = new UsersDAO();
            return usersDAO.UsersMenuListCheck(idusers, url);
        }
        #endregion
    }
}